package org.game.module.noticebo;

import com.sojoys.artifact.exception.AbstractLogicModelException;
import com.sojoys.artifact.factory.session.ISession;

import org.bean.AccountInfo;
import org.bean.NoticeDTO;
import org.game.cache.NoticeCache;
import org.game.constant.SessionConstent;
import org.game.db.bean.Player;
import org.game.msgBuilder.NoticeMsgBuilder;
import org.game.protobuf.c2s.C2SNoticeMsg;
import org.game.util.ProtoUnit;
import java.util.List;

/**
 * Created by fxf on 2018-1-9.
 */
public class NoticeBOImpl implements NoticeBO {

    @Override
    public byte[] getBillboardNotice(ISession session, C2SNoticeMsg.GetBillboardNotice msg) throws AbstractLogicModelException {
        Player player = session.getAttr(SessionConstent.PLAYER);
        AccountInfo info = player.getPlayerProxy().getAccountInfo();
        int channel = info.getChannelId();
        int channelAppId = info.getChannelAppId();
        List<NoticeDTO> noticeList = NoticeCache.getBillboardNotice(channel, channelAppId);
        return ProtoUnit.toByte(NoticeMsgBuilder.getBillBoardNoticeListMsg(noticeList));
    }
}
